hypervisor.h, dom0_ops.h, dom0_ops.c, dom0_defs.h:
Add a version number to the dom0_op interface, to prevent crashes and hangs with out-of-date user tools.
int ret = -1;
privcmd_hypercall_t hypercall;
+ op->interface_version = DOM0_INTERFACE_VERSION;
+
hypercall.op = __HYPERVISOR_dom0_op;
hypercall.arg[0] = (unsigned long)op;
}
if ( do_xen_hypercall(&hypercall) < 0 )
+ {
+ if ( errno == EINVAL )
+ fprintf(stderr, "Dom0 operation failed -- need to"
+ " rebuild the user-space tool set?\n");
goto out2;
+ }
ret = 0;
if ( copy_from_user(&op, u_dom0_op, sizeof(op)) )
return -EFAULT;
+ if ( op.interface_version != DOM0_INTERFACE_VERSION )
+ return -EINVAL;
+
switch ( op.cmd )
{
#include "hypervisor-if.h"
+/*
+ * Make sure you increment the interface version whenever you modify this file!
+ * This makes sure that old versions of dom0 tools will stop working in a
+ * well-defined way (rather than crashing the machine, for instance).
+ */
+#define DOM0_INTERFACE_VERSION 0xAAAA0001
+
/*
* The following is all CPU context. Note that the i387_ctxt block is filled
typedef struct dom0_op_st
{
unsigned long cmd;
+ unsigned long interface_version; /* DOM0_INTERFACE_VERSION */
union
{
dom0_createdomain_t createdomain;
static inline int HYPERVISOR_dom0_op(void *dom0_op)
{
int ret;
+ op->interface_version = DOM0_INTERFACE_VERSION;
__asm__ __volatile__ (
TRAP_INSTR
: "=a" (ret) : "0" (__HYPERVISOR_dom0_op),